class @FriendsIsAcceptedListingView extends ScrollPagingView
    
    initialize:->
        super
        @setElement("#main")
        @model.bind("change",@render)
        @model.fetch()

    render:->
        @GetTemplate(SiteMap.Friends.FriendsIsAcceptedListingEmptyTemplate,(template)=>
            $(@el).html(template(@model.toJSON()))
            @startLoading()
            @renewScrolling()
            return
        )

    events:
        "click a.accept":"accept"
        "click a.reject":"reject"


    accept:(event)->
        event.preventDefault()
        $.ajax(
            type:"POST"
            url:SiteMap.Friends.AddToFriends + "?friendLogin=" + $(event.currentTarget).data("friend-login")
            success:(response)=>
                @model.fetch()
        )
    
    reject:(event)->
        event.preventDefault()
        $.ajax(
            type:"POST"
            url:SiteMap.Friends.DeleteFromFriend + "?userId=" + @model.get("UserId") + "&friendId=" + $(event.currentTarget).data("friend-id")
            success:(response)=>
                @model.fetch()
        )

    afterLoad: (data) =>
        @GetTemplate(SiteMap.Friends.FriendsIsAcceptedListingTemplate, (compiledTemplate)=>
            $(@el).find("ul.friends-listing-accepted").append(compiledTemplate(data))
        )

